<?php
	defined('_JEXEC') or  die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
	if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');$config= VmConfig::loadConfig();
	if (!class_exists( 'VirtueMartModelVendor' )) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'vendor.php');
	if (!class_exists( 'TableMedias')) require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'medias.php');
	if (!class_exists( 'TableCategories')) require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'categories.php');
	if (!class_exists( 'VirtueMartModelCategory' )) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'category.php');
	function loadPreferredCategory(){
		$u = JFactory::getUser();
		//dump($u->id, 'uid');
		$db = JFactory::getDBO();
		$ql = "SELECT category_id FROM #__user_categories WHERE user_id='".$u->id."';";
		//dumpMessage($ql);
		$db->setQuery($ql);
		$r = $db->loadResult();
		$r = !empty($r)?(int) $r:0;	
		//dump($r,'preferedCategory');
		return $r;
	}
?>